javabook2
Class JavaBookDialog

java.lang.Object
  |
  +--javabook2.JavaBookDialog
Direct Known Subclasses:
InputBox, ListBox, MessageBox, MultiInputBox, ResponseBox

public abstract class JavaBookDialog
extends java.lang.Object

This abstract class defines behavior and data members common to javabook dialogs such as MessageBox, InputBox, and others. You can use this class as the superclass of your own dialog box. In this Swing version of javabook, the JOptionPane class is used extensively. Many functionalities coded inside the original javabook package are now handled automatically by the JOptionPane class.

This class is provided as freeware. You are free to use as provided or modify to your heart's content. But you use it at your own risk. No implied or explicit warranty is given.


Field Summary
static int ERROR_ICON
          Constant for the error icon
static int INFO_ICON
          Constant for the information icon
static int NO_ICON
          Constant for no icon
static int QUESTION_ICON
          Constant for the question icon
static int WARNING_ICON
          Constant for the warning icon
 
Constructor Summary
JavaBookDialog(java.awt.Component owner)
           
JavaBookDialog(java.awt.Component owner, boolean modal)
           
 
Method Summary
protected  void createDialog()
          Creates a dialog based on the values set for title, message, and icon.
protected  int getIcon()
          Returns the currently set icon.
protected  java.awt.Component getOwner()
          Returns the owner parent of this dialog
protected  java.lang.String getTitle()
          Returns the title of this dialog
 void setIcon(int icon)
          Sets the icon of this dialog
 void setLocation(int x, int y)
          Sets the location of this dialog.
protected  void setMessage(java.lang.Object message)
          Sets the message content of this dialog.
protected  void setModal(boolean modality)
          Sets the modality of this dialog.
 void setTitle(java.lang.String title)
          Sets the title of this dialog
protected  void show()
          Shows this dialog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ICON

public static final int NO_ICON
Constant for no icon

INFO_ICON

public static final int INFO_ICON
Constant for the information icon

ERROR_ICON

public static final int ERROR_ICON
Constant for the error icon

WARNING_ICON

public static final int WARNING_ICON
Constant for the warning icon

QUESTION_ICON

public static final int QUESTION_ICON
Constant for the question icon
Constructor Detail

JavaBookDialog

public JavaBookDialog(java.awt.Component owner)

JavaBookDialog

public JavaBookDialog(java.awt.Component owner,
                      boolean modal)
Method Detail

setIcon

public void setIcon(int icon)
Sets the icon of this dialog
Parameters:
icon - an icon to display on this dialog

setLocation

public void setLocation(int x,
                        int y)
Sets the location of this dialog.
Parameters:
x - the x coordinate of this dialog's origin relative to the screen
y - the y coordinate of this dialog's origin relative to the screen

setTitle

public void setTitle(java.lang.String title)
Sets the title of this dialog
Parameters:
title - a new title for this dialog

createDialog

protected void createDialog()
Creates a dialog based on the values set for title, message, and icon.

getIcon

protected int getIcon()
Returns the currently set icon.
Returns:
int the current set icon

getOwner

protected java.awt.Component getOwner()
Returns the owner parent of this dialog
Returns:
Component the owner parent of this dialog

getTitle

protected java.lang.String getTitle()
Returns the title of this dialog
Returns:
String the title of this dialog

setMessage

protected void setMessage(java.lang.Object message)
Sets the message content of this dialog. The message can be String, Component, Icon, or generic Object. String and Component are displayed as is, Icon is wrapped in a JLabel, and for generic Object, the String returned from toString is displayed.
Parameters:
Object - the message content of this dialog

setModal

protected void setModal(boolean modality)
Sets the modality of this dialog. This method is protected because its use should be restricted to the descendant classes. The client programmer should not be calling this method.
Parameters:
modality - true for modal; false for modeless

show

protected void show()
Shows this dialog